package com.example.administrator.intentbroadcast;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Intent_and_BroadCast extends AppCompatActivity {
    private Button button = null;
    private String nobody = "Who.care.the.name";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent_and__broad_cast);

        button = (Button)findViewById(R.id.myButton);

        button.setOnClickListener(new Button.OnClickListener() {
            @Override
            public void onClick(View v) {
                //生成一个Intent对象
                Intent intent = new Intent(nobody);
                //在Intent对象当中添加一个键值对
                intent.putExtra("testIntent", "123456789");
                sendBroadcast(intent);
            }
        });
    }


}
